package com.hps.demo.msg;

import com.alibaba.fastjson.JSON;
import javax.annotation.Resource;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

/**
 * @author heps
 * @since 2020/11/13 15:29
 */
@Component
public class KafkaSender {

  @Resource
  private KafkaTemplate<String, String> kafkaTemplate;

  public void send(String topic, Object data) {
    String value = JSON.toJSONString(data);
    kafkaTemplate.send(topic, value);
  }
}
